using System;
using System.IO;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Media.Imaging;
using Common;

namespace MainView.Windows
{
	public partial class AppStartWindow : Window, IComponentConnector
	{
		public AppStartWindow()
		{
			InitializeComponent();
			Ini();
		}

		private void Ini()
		{
			string path = Utility.GetApplicationPath() + "Splash.jpg";
			if (File.Exists(path))
			{
				try
				{
					FileStream fileStream = new FileStream(Utility.GetApplicationPath() + "Splash.jpg", FileMode.Open, FileAccess.Read);
					byte[] array = new byte[fileStream.Length];
					fileStream.Read(array, 0, array.Length);
					fileStream.Close();
					fileStream.Dispose();
					MemoryStream streamSource = new MemoryStream(array);
					BitmapImage bitmapImage = new BitmapImage();
					bitmapImage.BeginInit();
					bitmapImage.StreamSource = streamSource;
					bitmapImage.EndInit();
					img.Source = bitmapImage;
					return;
				}
				catch (Exception)
				{
					return;
				}
			}
			img.Source = new BitmapImage(new Uri("pack://application:,,,/Images;component/Other/Splash.jpg", UriKind.RelativeOrAbsolute));
		}
	}
}
